<?php

namespace app\admin\model;

use think\Model;
use traits\model\SoftDelete;

class Ydchuzhuang extends Model
{

    use SoftDelete;

    

    // 表名
    protected $name = 'ydchuzhuang';
    
    // 自动写入时间戳字段
    protected $autoWriteTimestamp = 'integer';

    // 定义时间戳字段名
    protected $createTime = 'createtime';
    protected $updateTime = 'updatetime';
    protected $deleteTime = 'deletetime';

    // 追加属性
    protected $append = [
        'ptype_text',
        'is_jiding_text',
        'is_quanwu_text',
        'is_quanguang_text',
        'is_kanjia_text',
        'gtype_text'
    ];
    

    
    public function getPtypeList()
    {
        return ['1' => __('Ptype 1'), '2' => __('Ptype 2'), '3' => __('Ptype 3'), '4' => __('Ptype 4'), '5' => __('Ptype 5'), '0' => __('Ptype 0')];
    }

    public function getIsJidingList()
    {
        return ['1' => __('Is_jiding 1'), '0' => __('Is_jiding 0')];
    }

    public function getIsQuanwuList()
    {
        return ['1' => __('Is_quanwu 1'), '0' => __('Is_quanwu 0')];
    }

    public function getIsQuanguangList()
    {
        return ['1' => __('Is_quanguang 1'), '0' => __('Is_quanguang 0')];
    }

    public function getIsKanjiaList()
    {
        return ['1' => __('Is_kanjia 1'), '0' => __('Is_kanjia 0')];
    }

    public function getGtypeList()
    {
        return ['1' => __('Gtype 1'), '2' => __('Gtype 2'), '3' => __('Gtype 3'), '4' => __('Gtype 4'), '5' => __('Gtype 5')];
    }


    public function getPtypeTextAttr($value, $data)
    {
        $value = $value ? $value : (isset($data['ptype']) ? $data['ptype'] : '');
        $list = $this->getPtypeList();
        return isset($list[$value]) ? $list[$value] : '';
    }


    public function getIsJidingTextAttr($value, $data)
    {
        $value = $value ? $value : (isset($data['is_jiding']) ? $data['is_jiding'] : '');
        $list = $this->getIsJidingList();
        return isset($list[$value]) ? $list[$value] : '';
    }


    public function getIsQuanwuTextAttr($value, $data)
    {
        $value = $value ? $value : (isset($data['is_quanwu']) ? $data['is_quanwu'] : '');
        $list = $this->getIsQuanwuList();
        return isset($list[$value]) ? $list[$value] : '';
    }


    public function getIsQuanguangTextAttr($value, $data)
    {
        $value = $value ? $value : (isset($data['is_quanguang']) ? $data['is_quanguang'] : '');
        $list = $this->getIsQuanguangList();
        return isset($list[$value]) ? $list[$value] : '';
    }


    public function getIsKanjiaTextAttr($value, $data)
    {
        $value = $value ? $value : (isset($data['is_kanjia']) ? $data['is_kanjia'] : '');
        $list = $this->getIsKanjiaList();
        return isset($list[$value]) ? $list[$value] : '';
    }


    public function getGtypeV($value)
    {
        $list = $this->getGtypeList();
        return isset($list[$value]) ? $list[$value] : '';
    }

    public function getGtypeTextAttr($value, $data)
    {
        $value = $value ? $value : (isset($data['gtype']) ? $data['gtype'] : '');
        $list = $this->getGtypeList();
        return isset($list[$value]) ? $list[$value] : '';
    }




    public function lanzhuang()
    {
        return $this->belongsTo('Lanzhuang', 'lanzhuang_id', 'id', [], 'LEFT')->setEagerlyType(0);
    }


    public function shouli()
    {
        return $this->belongsTo('Shouli', 'shouli_id', 'id', [], 'LEFT')->setEagerlyType(0);
    }
}
